package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaAbnormalDto;
import com.devilvan.betrice.aiqicha.po.AiqichaAbnormalPo;
import com.devilvan.betrice.aiqicha.service.AiqichaAbnormalService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaAbnormalMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaAbnormalRepository;
import org.springframework.stereotype.Service;
import com.devilvan.betrice.util.UCopy;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-企业经营异常信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaAbnormalServiceImpl extends ServiceImpl<AiqichaAbnormalMapper, AiqichaAbnormalPo> implements AiqichaAbnormalService {
    @Resource(name = "aiqichaAbnormalRepository")
    private AiqichaAbnormalRepository aiqichaAbnormalRepository;

    @Override
    public AiqichaAbnormalPo saveUpdate(AiqichaAbnormalDto aiqichaAbnormalDto) {
        AiqichaAbnormalPo aiqichaAbnormalPo = new AiqichaAbnormalPo();
        UCopy.fullCopy(aiqichaAbnormalDto, aiqichaAbnormalPo);
        return aiqichaAbnormalRepository.saveAndFlush(aiqichaAbnormalPo);
    }

    @Override
    public List<AiqichaAbnormalPo> saveUpdateBatch(List<AiqichaAbnormalDto> list) {
        List<AiqichaAbnormalPo> aiqichaAbnormalPoList = UCopy.fullCopyCollections(list, AiqichaAbnormalPo.class);
        return aiqichaAbnormalRepository.saveAllAndFlush(aiqichaAbnormalPoList);
    }
}
